#include "coordinates.h"

#include "eventHandler.h"

using namespace fortress;

COORD COORD::operator +(const COORD & otherOp) const
{
	COORD value;
	value.x=this->x+otherOp.x;
	value.y=this->y+otherOp.y;
	value.glyph=' ';
	value.color=TCODColor::black;
	return value;
}

COORD COORD::operator -(const COORD & otherOp) const
{
	COORD temp;
	temp.x=0-otherOp.x;
	temp.y=0-otherOp.y;
	return (*this + temp);
}

COORD COORD::operator +(const moveDirections & otherOp) const
{
	COORD value;
	value.x=this->x;
	value.y=this->y;
	if (otherOp==m_southwest || otherOp == m_west || otherOp == m_northwest)
		value.x=this->x-1;
	if (otherOp==m_northeast || otherOp == m_east || otherOp == m_southeast)
	value.x=this->x+1;
	if (otherOp==m_northwest || otherOp == m_north || otherOp == m_northeast)
		value.y=this->y-1;
	if (otherOp==m_southwest || otherOp == m_south || otherOp == m_southeast)
		value.y=this->y+1;
	return value;
}

COORD COORD::operator-(const moveDirections & otherOp) const
{
	int temp;
	// Flips around the direction
	if (otherOp > 3)
	{
		temp = otherOp-4;
	}
	else
	{
		temp = otherOp + 4;
	}
	return (*this + (moveDirections)temp);
}